package com.cherish.demo.controller;

import com.alibaba.fastjson.JSON;
import com.cherish.demo.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SuppressWarnings("unchecked")
@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Autowired
    TestService testService;

    @GetMapping("/select/{id}")
    public String select(@PathVariable long id) {
        long start = System.currentTimeMillis();
        String result = JSON.toJSONString(testService.selectById(id));
        log.info("耗时：{}毫秒", System.currentTimeMillis() - start);
        return result;
    }


}